package fr.miage.orleans.projetindus2014.utils;

import java.util.ArrayList;

import fr.miage.orleans.projetindus2014.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListeAdapter extends BaseAdapter{

	private ArrayList<ListeData> ld;
	private Activity context;
	public ListeAdapter(ArrayList<ListeData> ld1, Activity a){
		super();
		this.ld = ld1;
		this.context = a;
	}

	@Override
	public int getCount() {
		return ld.size();
	}

	@Override
	public Object getItem(int arg0) {
		return ld.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		//TextView vue = (TextView) context.getLayoutInflater().inflate(R.layout.ligne, null);
		//vue.setText(ld.get(position).getTitle());
		//return vue;
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.row, parent, false);
		TextView title = (TextView) rowView.findViewById(R.id.titleLign);
		TextView d = (TextView) rowView.findViewById(R.id.dLign);
		TextView d1 = (TextView) rowView.findViewById(R.id.dLign2);
		TextView d2 = (TextView) rowView.findViewById(R.id.dLign3);
		title.setText(ld.get(position).getTitle());
		d.setText(ld.get(position).getDetails());
		d1.setText(ld.get(position).getDetails2());
		d2.setText(ld.get(position).getDetails3());
		return rowView;

	}


}
